package com.hp.team.bookstore.model.profile;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Profile {

	/*
	 * Use "GenerationType.TABLE" for table-per-class inheritance strategy.
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	@Column(name = "ID")
	private long id;

	@Column(name = "FIRST_NAME")
	private String firstName;

	@Column(name = "LAST_NAME")
	private String lastName;

	@Enumerated(EnumType.STRING)
	@Column(name = "GENDER")
	private Gender gender;

	@Embedded
	@AttributeOverrides(value = { @AttributeOverride(name = "buildingNumber", column = @Column(name = "HOME_ADDRESS_BUILDING_NUMBER")),
			@AttributeOverride(name = "street", column = @Column(name = "HOME_ADDRESS_STREET")),
			@AttributeOverride(name = "state", column = @Column(name = "HOME_ADDRESS_STATE")),
			@AttributeOverride(name = "zipCode", column = @Column(name = "HOME_ADDRESS_ZIP_CODE")),
			@AttributeOverride(name = "city", column = @Column(name = "HOME_ADDRESS_CITY")),
			@AttributeOverride(name = "country", column = @Column(name = "HOME_ADDRESS_COUNTRY")) })
	private Address address;

	@Embedded
	@AttributeOverrides(value = { @AttributeOverride(name = "countryCode", column = @Column(name = "HOME_TELEPHONE_COUNTRY_CODE")),
			@AttributeOverride(name = "number", column = @Column(name = "HOME_TELEPHONE_NUMBER")) })
	private Telephone telephone;

	@Column(name = "EMAIL")
	private String email;

	public void setId(long id) {
		this.id = id;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public void setTelephone(Telephone telephone) {
		this.telephone = telephone;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public long getId() {
		return id;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public Gender getGender() {
		return gender;
	}

	public Address getAddress() {
		return address;
	}

	public Telephone getTelephone() {
		return telephone;
	}

	public String getEmail() {
		return email;
	}
}
